﻿using Demo.Abp.Extension;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;

namespace Demo.OrderManager;

[DependsOn(
    typeof(OrderManagerApplicationContractsModule),
    typeof(AbpHttpClientModule))]
public class OrderManagerHttpApiClientModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddTransient<AddHeaderHandler>();
        context.Services.AddHttpClient(OrderManagerRemoteServiceConsts.RemoteServiceName)
            .AddHttpMessageHandler<AddHeaderHandler>();
        
        context.Services.AddHttpClientProxies(
            typeof(OrderManagerApplicationContractsModule).Assembly,
            OrderManagerRemoteServiceConsts.RemoteServiceName
        );

        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<OrderManagerHttpApiClientModule>();
        });

    }
}